package com.example.springcloud.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.example.springcloud.domain.ScenicSpots;
import com.example.springcloud.service.IScenicSpotsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 景点信息Controller
 * 
 * @author helian
 * @date 2025-03-01
 */
@RestController
@RequestMapping("/jiu-mount-huangshan/spots")
@Api(tags = "景点信息管理")
public class ScenicSpotsController extends BaseController
{
    @Autowired
    private IScenicSpotsService scenicSpotsService;

    /**
     * 查询景点信息列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询景点信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = false, dataType = "Long")})
    @ApiResponses(@ApiResponse(code = 200, message = "查询景点信息列表成功", response = ScenicSpots.class , responseContainer = "List"))
    public TableDataInfo list(ScenicSpots scenicSpots, Long userId)
    {
        startPage();
        List<ScenicSpots> list = scenicSpotsService.selectScenicSpotsList(scenicSpots,userId);
        return getDataTable(list);
    }


    /**
     * 获取景点信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:spots:query')")
    @GetMapping(value = "/{scenicId}")
    public AjaxResult getInfo(@PathVariable("scenicId") Long scenicId)
    {
        return success(scenicSpotsService.selectScenicSpotsByScenicId(scenicId));
    }

    /**
     * 新增景点信息
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:spots:add')")
    @Log(title = "景点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScenicSpots scenicSpots)
    {
        return toAjax(scenicSpotsService.insertScenicSpots(scenicSpots));
    }

    /**
     * 修改景点信息
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:spots:edit')")
    @Log(title = "景点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScenicSpots scenicSpots)
    {
        return toAjax(scenicSpotsService.updateScenicSpots(scenicSpots));
    }

    /**
     * 删除景点信息
     */
    @PreAuthorize("@ss.hasPermi('jiu-mount-huangshan:spots:remove')")
    @Log(title = "景点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scenicIds}")
    public AjaxResult remove(@PathVariable Long[] scenicIds)
    {
        return toAjax(scenicSpotsService.deleteScenicSpotsByScenicIds(scenicIds));
    }
}
